// Ofri Keidar 302933981 group 05

package model.database;

import java.util.List;
import model.apartment.Apartment;
import model.building.Building;

/**
 * Database to store the apartments and buildings. Can answer queries and return the relevant apartments/buildings
 * and add buildings
 */
public interface Database {

	/**
	 * Returns all vacant apartments in database.
	 * Apartments are sorted by total area in ascending order
	 * @return all vacant apartments in database
	 * @throws DBException- throws database exception if could not communicate with database
	 */
	public List<Apartment> getVacantApartments() throws DBException;
	
	/**
	 * Returns all vacant apartments of given type in database
	 * @param type- apartment type to look for
	 * @return all vacant apartments of given type in database
	 * @throws DBException- throws database exception if could not communicate with database
	 */
	public List<Apartment> getVacantApartments(String type) throws DBException;
	
	/**
	 * Returns all vacant apartments of given type with specified room number in database.
	 * Apartments are sorted by total area in ascending order
	 * @param type- apartment type to look for
	 * @param roomNum- room number to look for
	 * @return all vacant apartments with given parameters
	 * @throws DBException- throws database exception if could not communicate with database
	 */
	public List<Apartment> getVacantApartments(String type, double roomNum)
			throws DBException;
	
	/**
	 * Returns all vacant apartments assigned to building with given ID in database.
	 * Apartments are sorted by total area in ascending order
	 * @param buildingID- building ID to look for
	 * @return all vacant apartments with given parameters
	 * @throws DBException- throws database exception if could not communicate with database
	 */
	public List<Apartment> getVacantApartments(int buildingID)
			throws DBException;
	
	/**
	 * Returns all vacant apartments of given type, with specified room number,
	 * assigned to building with given ID.
	 * Apartments are sorted by total area in ascending order
	 * @param type- apartment type to look for
	 * @param roomNum- room number to look for
	 * @param buildingID- building ID to look for
	 * @return all vacant apartments with given parameters
	 * @throws DBException- throws database exception if could not communicate with database
	 */
	public List<Apartment> getVacantApartments(String type, double roomNum,
			int buildingID) throws DBException;

	/**
	 * Returns all apartments of given type in database.
	 * Apartments are sorted by total area in ascending order
	 * @param type- apartment type to look for
	 * @return all apartments of given type in database
	 * @throws DBException- throws database exception if could not communicate with database
	 */
	public List<Apartment> getApartments(String type) throws DBException;
	
	/**
	 * Returns all apartments of given type, assigned to building with given ID.
	 * Apartments are sorted by total area in ascending order
	 * @param type- apartment type to look for
	 * @param buildingID building ID to look for
	 * @return all apartments with given parameters
	 * @throws DBException- throws database exception if could not communicate with database 
	 */
	public List<Apartment> getApartments(String type, int buildingID)
			throws DBException;

	/**
	 * Returns building at given address
	 * @param stName- building's street
	 * @param bldNumber- buildings number on street
	 * @return building at given address, null if no building at given address
	 * @throws DBException- throws database exception if could not communicate with database
	 */
	public Building getBuildingByAddress(String stName, int bldNumber)
			throws DBException;

	/**
	 * Adds given building to database
	 * @param buildingToAdd- building to add
	 * @return True if could add, False if not
	 * @throws DBException- throws database exception if could not communicate with database
	 */
	public boolean addBuilding(Building buildingToAdd) throws DBException;
	
	/**
	 * Updates apartment at given address with given resident name
	 * @param stName- apartment's address street name
	 * @param bldNumer- apartemtnt's address building number
	 * @param newResName- new resident name for the apartment
	 * @return True if could update resident name, False if not
	 * @throws DBException- throws database exception if could not communicate with database
	 */
	public boolean updateResident(String newResName, int buildingID,
			int apartmentNum) throws DBException;
	
	/**
	 * Returns how many buildings are in database
	 * @return number of buildings in database
	 * @throws DBException- throws database exception if could not communicate with database
	 */
	public int countBuildings() throws DBException;
}